@extends('app')

@section('content')
<ul class="nav nav-tabs">
    <li ><a href="{{ url('/admin/bbs/category')}}">板块列表</a></li>
    <li class="active"><a href="{{ url('/admin/bbs/category/create') }}">添加板块</a></li>
</ul>
<form method="POST" action="{{ url('/admin/bbs/category') }}">
<div class="panel panel-default description2 mt20">
    <div class="table-responsive panel-body">
        <table class="table table-hover">
            <tr>
                <td>
                    <div class="form-group">
                        <span class="col-sm-4 col-xs-3 control-label">板块名称:</span>
                        <div class="col-sm-5 col-xs-8">
                            <input type="text" class="form-control" name="name" id="name" @if(count($cates) > 0) value="{{ $cates->title }}" @endif>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    @if($blademode == "edit")
                    <div class="form-group">
                        <span class="col-sm-4 col-xs-3 control-label">选择板块:</span>
                        <div class="col-sm-5 col-xs-8">
                            <select name="type" class="form-control" id="type" onchange="getChilds(this.value,'parent')">
                                <option value="0">无</option>
                                @foreach($category as $tp)
                                <option value="{{ $tp->id }}" @if($tp->id == $cates->parent_id) selected @endif>{{ $tp->title }}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>
                    @else
                        <div class="form-group">
                            <span class="col-sm-4 col-xs-3 control-label">父级板块:</span>
                            <div class="col-sm-5 col-xs-8">
                                <select name="type" class="form-control" id="type" >
                                    <option value="0">无</option>
                                    @foreach($category as $tp)
                                    <option value="{{ $tp->id }}" @if($tp->id == $catid) selected @endif>{{ $tp->title }}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                    @endif
                </td>
            </tr>
            <tr>
                <td>
                    <div class="form-group">
                        <span class="col-sm-4 col-xs-3 control-label">板块排序:</span>
                        <div class="col-sm-5 col-xs-8">
                            <input type="number" class="form-control" name="sort" id="sort" @if( count($cates) > 0) value="{{ $cates->sort }}" @endif>
                            <div class="help-block" >越小越靠前</div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="form-group">
                        <span class="col-sm-4 col-xs-3 control-label">热门板块:</span>
                        <div class="col-sm-5 col-xs-8">
                            <label class="radio-inline">
                              <input type="radio" name="is_hot" id="is_hot" value="1"> 是
                            </label>
                            <label class="radio-inline">
                              <input type="radio" name="is_hot" id="is_hot" value="0" checked> 否
                            </label>
                            <div class="help-block" >越小越靠前</div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="form-group">
                        <span class="col-sm-4 col-xs-3 control-label">板块图标:</span>
                        <div class="col-sm-5 col-xs-8">
                            <input id="uploadimg" name="uploadimg" type="file" multiple="true" />
                            <div id="imgbox" class="dustbin">
                                @if(count($cates) > 0)
                                <div style="width:90px; height:60px;">
                                    <img width="90" height="60" src="{{$cates->icon}}" />
                                    <input type='hidden' name='icon' value='{{$cates->icon}}' />
                                </div>
                                @endif
                            </div>
                        </div>
                    </div>
                </td>
            </tr>
        </table>
        </div>
    </div>
    {!! csrf_field() !!}
    <div class="form-inline mt20">
        <div class="form-group">
          <input type="hidden" name="stauts" value="1">
          <input type="submit" class="btn btn-info" id="save" value="submit" />
        </div>
        <div class="form-group ml30">
            <input type="reset" class="btn" value="reset" />
        </div>
    </div>
</form>

<script type="text/javascript">
<!--
$(function(){
	/***图片上传****/
	$("#uploadimg").uploadify({
	    'formData'     : {
	        'fileField':'upfile',
	        '_token':'{{ csrf_token() }}',
	        'type':'bbs'
	    },
	    "width"           : 120,
	    "height"          : 30,
	    "queueSizeLimit"  :1,
	    "swf"             : "{{ asset('/js/uploadify/uploadify.swf') }}",
	    "fileObjName"     : "upfile",
	    "buttonText"      : "上传图片",
	    "uploader"        : '/admin/upload/newsimage',
	    'removeTimeout'	  : 1,
	    'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
	    'onUploadSuccess':function(file, data, response){
	    	var data = eval('(' + data + ')');
	        if (data.status == 'success') {

	        	var html="<div style='width:90px; height:60px;float:left;'>"
	            			+"<img width='90' height='60' src='"+data.url+"'  /><input type='hidden' name='icon' value='"+data.url+"' />"
	            			+"</div>"
	            $('#imgbox').html(html);
	        }else{
	            alert(data.msg);
	            return false;
	        }

	    }

	});
});
//-->
</script>
@endsection
